/**
 * 用户列表
 */
<template>
  <div>
    <div v-if="isUser">
      <!-- 面包屑导航 -->
      <el-breadcrumb separator-class="el-icon-arrow-right" class="margin-t10">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="boxBlock"> 
        <div class="serachTop"> 
             <!-- 搜索筛选 -->
            <el-form :inline="true" :model="formInline" class="user-search">
              <el-form-item >
                <el-input
                  size="small"
                  v-model="formInline.userId"
                  placeholder="输入账号ID"
                  type="number"
                  clearable
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-input
                  size="small"
                  v-model="formInline.loginName"
                  placeholder="输入账号名称"
                  clearable
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-select
                  size="small"
                  v-model="formInline.authType"
                  placeholder="请选择认证状态"
                  clearable
                >
                  <el-option label="请选择认证状态" value=""></el-option>
                  <el-option
                    v-for="type in statusData"
                    :label="type.key"
                    :value="type.value"
                    :key="type.value"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item> 
              <el-select
                size="small"
                v-model="formInline.compute"
                placeholder="请选择开启关闭"
                clearable
              > 
                <el-option 
                  label="不统计"
                  :value="0" 
                ></el-option>
                <el-option 
                  label="统计"
                  :value="1" 
                ></el-option>
              </el-select>
            </el-form-item> 
              <el-form-item>
                <el-button
                  size="small"
                  type="primary"
                  icon="el-icon-search"
                  @click="search"
                >
                  搜索
                </el-button>
                <el-button size="small" type="primary" icon="el-icon-download" @click="exportEx()">
                  导出
                </el-button>
              </el-form-item>
            </el-form>
        </div>
     
     
      <!--列表-->
      <div class="ra_box">
        <el-table
          size="small"
          :data="listData"
          highlight-current-row
          v-loading="loading"
          element-loading-text="拼命加载中"
          style="width: 100%"
        >
          <el-table-column prop="userId" label="用户ID" min-width="80">
          </el-table-column>
          <el-table-column prop="params.iamCount" label="IAM" min-width="120"> </el-table-column> 
          <el-table-column
            prop="loginName"
            label="账户名称"
            min-width="160"
            show-overflow-tooltip
          >
          </el-table-column>
          <!-- <el-table-column prop="userName" label="昵称" show-overflow-tooltip>
          </el-table-column>  -->
        <el-table-column prop="balance" label="中心钱包余额" min-width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            <div @click="showBalance(scope.row)" style="color: #2e3094;">{{ b(scope.row.balance) }}</div>
          </template>
        </el-table-column>

        <el-table-column prop="freezeBalance" label="冻结金额" min-width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ b(scope.row.freezeBalance) }}
          </template>
        </el-table-column> 
       
        <el-table-column prop="matrixBalance" label="星链共享卡钱包余额" min-width="160" show-overflow-tooltip > 
          <template slot-scope="scope">
            <div>{{ b(scope.row.matrixBalance) }}</div>
          </template>
        </el-table-column>

        <!-- 中心钱包余额，星链共享卡钱包余额，星链共享卡余额(实时)，星链常规卡余额，星汇共享卡钱包余额，星汇共享卡余额(实时) -->
 
        <el-table-column prop="realTimeBalance" label="星链共享卡余额(实时)" min-width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            <div>{{ b(scope.row.realTimeBalance) }}</div>
          </template>
        </el-table-column>   

        <el-table-column
          prop="cardBalance"
          label="星链常规卡余额"
          min-width="160"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <div>
              {{
                b(
                  scope.row.params.cardBalance
                    ? scope.row.params.cardBalance
                    : 0
                )
              }}
            </div>
          </template>
        </el-table-column> 
        

        <el-table-column
          prop="budgetBalance"
          label="星汇共享卡钱包余额"
          min-width="160"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <div>
              {{
                b(
                  scope.row.params.budgetBalance
                    ? scope.row.params.budgetBalance
                    : 0
                )
              }}
            </div>
          </template>
        </el-table-column> 
        <el-table-column prop="budgetRealTimeBalance" label="星汇共享卡余额(实时)" min-width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            <div>{{ b(scope.row.budgetRealTimeBalance) }}</div>
          </template>
        </el-table-column>   
<!--         
          <el-table-column
            prop="balance"
            label="账户余额"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <div>{{ b(scope.row.balance) }}</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="cardBalance"
            label="卡余额"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <div>
                {{
                  b(
                    scope.row.params.cardBalance
                      ? scope.row.params.cardBalance
                      : 0
                  )
                }}
              </div>
            </template>
          </el-table-column> -->
          <el-table-column prop="count" label="卡Bin" show-overflow-tooltip>
            <template slot-scope="scope">
              <div>{{ scope.row.params.count }}</div>
            </template>
          </el-table-column>

          <el-table-column
          prop="refuseCount"
          label="拒付率"
          show-overflow-tooltip
          min-width="120"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.params.refuseCount>=0">
              {{
                scope.row.params.transactionCount == 0
                  ? "0%"
                  : (
                      (scope.row.params.refuseCount /
                      (scope.row.params.transactionAmount-scope.row.params.voidCount)) *
                      100
                    ).toFixed(0) + "%"
              }}
            </div>
            <div v-else>-</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="refundCount"
          label="退款率"
          show-overflow-tooltip
          min-width="120"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.params.refundCount>=0">
              {{
                scope.row.params.transactionCount == 0
                  ? "0%"
                  : (
                      (scope.row.params.refundCount /
                          (scope.row.params.transactionAmount-scope.row.params.voidCount)) *
                      100
                    ).toFixed(0) + "%"
              }}
            </div>
            <div v-else>-</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="refundAmount"
          label="退款金额率"
          show-overflow-tooltip min-width="120"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.params.refundAmount>=0">
              {{
                scope.row.params.transactionAmount == 0
                  ? "0%"
                  : (
                      (scope.row.params.refundAmount /
                      (scope.row.params.transactionAmount-scope.row.params.voidAmount)) *
                      100
                    ).toFixed(0) + "%"
              }}
            </div>
            <div v-else>-</div>
          </template>
        </el-table-column>


          <!-- <el-table-column
            prop="refuseCount"
            label="拒付率"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <div v-if="scope.row.params.refuseCount&&scope.row.params.transactionCount">
                {{
                  scope.row.params.transactionCount == 0
                    ? "0%"
                    : (
                        (scope.row.params.refuseCount /
                          scope.row.params.transactionCount) *
                        100
                      ).toFixed(0) + "%"
                }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="refundCount"
            label="退款率"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <div v-if="scope.row.params.transactionCount&&scope.row.params.refundCount">
                {{
                  scope.row.params.transactionCount == 0
                    ? "0%"
                    : (
                        (scope.row.params.refundCount /
                          scope.row.params.transactionCount) *
                        100
                      ).toFixed(0) + "%"
                }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="refundAmount"
            label="退款金额率"
            show-overflow-tooltip
            min-width="160"
          >
            <template slot-scope="scope">
              <div v-if="scope.row.params.transactionAmount&&scope.row.params.refundCount">
                {{
                  scope.row.params.transactionAmount == 0
                    ? "0%"
                    : (
                        (scope.row.params.refundAmount /
                          scope.row.params.transactionAmount) *
                        100
                      ).toFixed(0) + "%"
                }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column> -->
          <!-- <el-table-column
            prop="shareCardCount"
            label="配置共享卡"
            show-overflow-tooltip
            v-if="hasPermissionMethod(['admin7'])"  
            min-width="160"
          >
            <template slot-scope="scope">
              <i
                class="el-icon-edit-outline font18 font-w6 margin-l5"
                @click="handleShare(scope.$index, scope.row)"
              >
              </i>
              {{ scope.row.shareCardCount }}
            </template>
          </el-table-column> -->
          <el-table-column
            prop="shareCardCount"
            label="共享卡账户"
            show-overflow-tooltip 
            min-width="300"
          >
            <template slot-scope="scope"> 
              <label v-if="scope.row.matrixAccount"> 
                <el-tooltip class="item" effect="dark" :content="scope.row.matrixAccount" placement="left-start">  
                  <el-button  size="mini"  
                  style="color: #2e3094; cursor: pointer;">
                  <!-- <i class="el-icon-info"></i> -->
                  账号
                </el-button>
              </el-tooltip>
                <el-button  size="mini"  
                  style="color: #2e3094; cursor: pointer;"   @click="changeGongZhuan(scope.row,'1')" >转出</el-button>
                <el-button  size="mini"  
                  style="color: #2e3094; cursor: pointer;"   @click="changeGongZhuan(scope.row,'2')" >转入</el-button>  
              </label> 
              <el-button  size="mini"  
                style="color: #2e3094; cursor: pointer;" v-else @click="changeGongSwitch(scope.row)" >开启</el-button>
            </template>
          </el-table-column>

          <el-table-column
            prop="budgetAccountId"
            label="开通万里汇共享卡"
            show-overflow-tooltip 
            min-width="300"
          >
            <template slot-scope="scope"> 
              <label v-if="scope.row.budgetAccountId"> 
                <el-tooltip class="item" effect="dark" :content="scope.row.budgetAccountId" placement="left-start">  
                  <el-button  size="mini"  
                  style="color: #2e3094; cursor: pointer;">
                  <!-- <i class="el-icon-info"></i> -->
                  账号
                </el-button>
              </el-tooltip>
                <el-button  size="mini"  
                  style="color: #2e3094; cursor: pointer;"   @click="changeBudgetAccount(scope.row,'1')" >转出</el-button>
                <el-button  size="mini"  
                  style="color: #2e3094; cursor: pointer;"   @click="changeBudgetAccount(scope.row,'2')" >转入</el-button>  
              </label> 
              <el-button  size="mini"  
                style="color: #2e3094; cursor: pointer;" v-else @click="openBudgetAccount(scope.row)" >开启</el-button>
            </template>
          </el-table-column> 
          
          <el-table-column
            prop="authType"
            label="是否为代理商"  min-width="260"
          >
            <template slot-scope="scope"> 
              
              <el-switch
                v-model="scope.row.agent"
                active-color="#2e3094"
                :min-width="60"
                :activeValue="true"
                :inactiveValue="false" 
                @change="verArry.includes('/api/admin/setAgent')?changeSwitchVer(scope.row):changeSwitch($event,scope.row)" 
                :disabled="scope.row.authType==2&&scope.row.invitationCode==1?false:true"
                inactive-color="#eeeeee">
              </el-switch>

              <span v-if="scope.row.agent==1">  
                <el-tooltip class="item" effect="dark" content="复制链接注册会员后成为该客户的下级客户" placement="top">
                    <el-button
                      size="mini" plain 
                      v-copy="`${hostname}#/register?invitationCode=${scope.row.userId}`"  
                    >
                    复制
                  </el-button>
                </el-tooltip> 
              </span> 
            </template>
          </el-table-column> 
          <el-table-column
            prop="params.agentCount"
            label="代理商数量"  min-width="160"
          >
            <template slot-scope="scope" > 
              <!-- <span  style="color:#2e3094" >{{ scope.row.params.agentCount }}</span> -->
              {{ scope.row.params.agentCount }}
              <i
                class="el-icon-edit-outline"
                @click="agantNumber(scope.row)"
                v-if="scope.row.agent==1"
              >
              </i>
             
            </template> 
          </el-table-column>
          <el-table-column
            prop=" invitationCode"
            label="上级代理"  min-width="160"
          >
            <template slot-scope="scope">
              {{  scope.row.invitationCode==1?'平台':scope.row.invitationCode }}
            </template> 
          </el-table-column> 
          
          <el-table-column
            prop="authType"
            label="企业认证"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <div>{{ statusJson[scope.row.authType].key }}</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="createTime"
            label="创建时间"
            show-overflow-tooltip
          >
          </el-table-column> 

          <!-- <el-table-column prop="remark" label="备注" show-overflow-tooltip>
        </el-table-column> -->
          <el-table-column align="center" label="操作" width="200" fixed="right"> 
            <template slot-scope="scope">
              <el-button size="mini" plain @click="changUser(false, scope.row)"   v-if="hasPermission5">
                查看
              </el-button>
              <!-- <el-button
                size="mini"
                type="success"
                @click="handleShare(scope.$index, scope.row)"
              >
                共享卡
              </el-button> -->  
              <el-dropdown>
                <el-button type="primary" size="mini" style="margin:0 10px">
                  更多操作<i class="el-icon-arrow-down el-icon--right"></i>
                </el-button>
                <el-dropdown-menu slot="dropdown"> 
                  <el-dropdown-item v-if="hasPermission5">
                    <el-button
                      size="mini"
                      plain
                      @click="handleReset(scope.$index, scope.row)"
                      style="color: #999; cursor: pointer;" 
                    >
                      重置 
                    </el-button> 
                  </el-dropdown-item>
                  <el-dropdown-item  v-if="hasPermission6">
                    <el-button
                      size="mini" 
                      @click="handleEdit(scope.$index, scope.row)"
                      style="color: #67C23A; cursor: pointer;" 
                    >
                      充值
                    </el-button>
                  </el-dropdown-item>
                  <el-dropdown-item  v-if="hasPermission6"  >
                    <el-button
                      size="mini" 
                      @click="handleCut(scope.$index, scope.row)" 
                    >
                      扣款
                    </el-button>  
                  </el-dropdown-item>
                  <el-dropdown-item  v-if="hasPermission5"  >
                    <el-button size="mini"  @click="handleUser(scope.$index, scope.row)"> 
                      <label v-if="scope.row.status == 1" style="color: #67C23A; cursor: pointer;">启用</label>
                      <label v-if="scope.row.status == 0" style="color: #f74e4e; cursor: pointer;">停用</label>
                    </el-button> 
                  </el-dropdown-item>
                  <el-dropdown-item  v-if="hasPerDel"  >
                    <el-button
                      size="mini" 
                      @click="delUser(scope.$index, scope.row)"
                      style="color: #f74e4e; cursor: pointer;" 
                    >
                      删除
                    </el-button>
                  </el-dropdown-item>  
                  <el-dropdown-item   >
                    <el-button
                      size="mini" 
                      @click="dongUser(scope.$index, scope.row,'freeze')"
                      style="color: #67C23A; cursor: pointer;" 
                    >
                      解冻
                    </el-button>
                  </el-dropdown-item>  
                  <el-dropdown-item   >
                    <el-button
                      size="mini" 
                      @click="dongUser(scope.$index, scope.row,'unfreeze')"
                      style="color: #f74e4e; cursor: pointer;" 
                    >
                      冻结 
                    </el-button>
                  </el-dropdown-item>  
                   
                </el-dropdown-menu>
              </el-dropdown> 


              <!-- <el-button
                size="mini"
                plain
                @click="handleReset(scope.$index, scope.row)"
                style="color: #999; cursor: pointer;" v-if="hasPermission5"
              >
                重置 
              </el-button> 
              <el-button
                size="mini" 
                @click="handleEdit(scope.$index, scope.row)"
                style="color: #67C23A; cursor: pointer;"   v-if="hasPermission6"
              >
                充值
              </el-button>
              <el-button
                size="mini"
               
                @click="handleCut(scope.$index, scope.row)"   v-if="hasPermission6"
              >
                扣款
              </el-button>  
              <el-button size="mini"  @click="handleUser(scope.$index, scope.row)" v-if="hasPermission5"> 
                 <label v-if="scope.row.status == 1" style="color: #67C23A; cursor: pointer;">启用</label>
                 <label v-if="scope.row.status == 0" style="color: #f74e4e; cursor: pointer;">停用</label>
              </el-button> 
              <el-button
                size="mini" 
                @click="delUser(scope.$index, scope.row)"
                style="color: #f74e4e; cursor: pointer;"
                v-if="hasPerDel" 
              >
                删除
              </el-button> -->
              
            
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 分页组件 -->
      <Pagination
        v-bind:child-msg="pageparm"
        @callFather="callFather"
      ></Pagination>
    </div>
      <!-- 充值界面 -->
      <el-dialog
        :close-on-click-modal="false"
        title="充值"
        :visible.sync="addFormVisible"
        min-width="30%"
        @close="closeDialog('addForm')"
      >
        <el-form
          :model="addForm"
          :rules="rulesAdd"
          ref="addForm"
          label-min-width="100px"
          label-position="left"
          style="50%"
        >
          <el-form-item label="充值金额" prop="rechargeAmount" class="wid-9">
            <el-input
              size="small"
              v-model="addForm.rechargeAmount"
              auto-complete="off"
              placeholder="请输入充值金额xxx"
            ></el-input>
          </el-form-item>
          <el-form-item label="到账金额" prop="amount" class="wid-9">
            <el-input
              size="small"
              v-model="addForm.amount"
              auto-complete="off"
              placeholder="请输入到账xxx"
            ></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="remark" class="wid-9">
            <el-input
              size="small"
              v-model.trim="addForm.remark"
              auto-complete="off"
              type="textarea"
              :rows="5"
              placeholder="请输入备注"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="closeDialog()">取消</el-button> 
          <el-button
            size="small"
            type="primary"
            :loading="loading"
            class="title"
            @click="verArry.includes('/api/admin/supporterRecharge')?RechargeVer():submitFormAdd()"
            :disabled="disabled"
            >充值</el-button
          >
        </div>
      </el-dialog>
      <!-- 扣款界面 -->
      <el-dialog
        :close-on-click-modal="false"
        title="扣款"
        :visible.sync="cutFormVisible"
        min-width="30%"
        @close="closeDialog('cutForm')"
      >
        <el-form
          :model="cutForm"
          :rules="rulesCut"
          ref="cutForm"
          label-min-width="100px"
          label-position="left"
          style="50%"
        >
          <el-form-item
            label="账户余额"
            prop="balance"
            v-if="uitemInfo"
            class="wid-10"
          >
            {{ b(uitemInfo.balance) }}
          </el-form-item>
          <el-form-item label="扣款金额" prop="amount" class="wid-9">
            <el-input
              size="small"
              v-model="cutForm.amount"
              auto-complete="off"
              placeholder="请输入扣款金额xxx"
            ></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="remark" class="wid-9">
            <el-input
              size="small"
              v-model.trim="cutForm.remark"
              auto-complete="off"
              type="textarea"
              :rows="5"
              placeholder="请输入备注"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="closeDialog('cutForm')">
            取消
          </el-button>
          <!-- @click="submitFormCut()" -->
          <el-button
            size="small"
            type="primary"
            :loading="loading"
            class="title"
            
            @click=" verArry.includes('/api/admin/supporterWithhold')?FormCutVer():submitFormCut()"
            :disabled="disabled"
            >提交</el-button
          >
        </div>
      </el-dialog>
      <!-- 重置密码  -->
      <el-dialog
        :close-on-click-modal="false"
        title="重置密码"
        :visible.sync="resetFormVisible"
        min-width="30%"
        @close="closeDialog"
      >
        <el-form
          :model="resetForm"
          :rules="rulesReset"
          ref="resetForm"
          label-min-width="120px"
          label-position="left"
          style="50%"
        >
          <el-form-item label="新密码" prop="password">
            <el-input
              size="small"
              show-password
              v-model="resetForm.password"
              auto-complete="off"
              placeholder="请输入新密码"
            ></el-input>
          </el-form-item>
          <el-form-item label="再次确认密码" prop="confirmPassword">
            <el-input
              size="small"
              v-model="resetForm.confirmPassword"
              auto-complete="off"
              show-password
              placeholder="请再次确认密码"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="closeDialog('resetForm')"
            >取消</el-button
          >
          <el-button
            size="small"
            type="primary"
            :loading="loading"
            class="title"
            @click="submitFormReset()"
            :disabled="disabled"
            >提交</el-button
          >
        </div>
      </el-dialog>
      <!-- 共享卡  -->
      <el-dialog
        :close-on-click-modal="false"
        title="配置共享卡"
        :visible.sync="shareFormVisible"
        min-width="30%"
        @close="closeDialog('shareForm')"
      >
        <el-form
          :model="shareForm"
          :rules="rulesShare"
          ref="shareForm"
          label-min-width="150px"
          label-position="left"
          style="50%"
        >
          <el-form-item label="可开通共享卡" prop="shareCardCount">
            <el-input
              size="small"
              v-model="shareForm.shareCardCount"
              auto-complete="off"
              placeholder="请输入可开通共享卡数量"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="closeDialog('shareForm')"
            >取消</el-button
          > 
 
          <el-button
            size="small"
            type="primary"
            :loading="loading"
            class="title" 
            @click="verArry.includes('/api/admin/setShareCardNum')?changeShareVer():submitFormShare()"   
            :disabled="disabled"
            >提交</el-button
          >
        </div>
      </el-dialog>

      <!-- 冻结、解冻 -->
      <el-dialog
        :close-on-click-modal="false"
        :title="freezeBalanceTitle"
        :visible.sync="freezeBalanceVisible" 
        min-width="30%"
        @close="closeDialog('freezeBalance')"
      >
        <el-form
          :model="freezeBalanceForm"
          :rules="rulesfreezeBalance"
          ref="freezeBalanceForm"
          label-width="100px"
          label-position="left"
          style="50%"
        >
          <el-form-item label="金额" prop="amount">
            <el-input
              size="small"
              v-model="freezeBalanceForm.amount"
              auto-complete="off"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item label="备注" prop="remark" class="wid-9">
            <el-input
              size="small"
              v-model.trim="freezeBalanceForm.remark"
              auto-complete="off"
              type="textarea"
              :rows="5"
              placeholder="请输入备注"
            ></el-input>
          </el-form-item>
        </el-form>
       
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="closeDialog('freezeBalance')"
            >取消</el-button
          >  
          <el-button
            size="small"
            type="primary"
            :loading="loading"
            class="title" 
            @click="verArry.includes('/api/admin/unFreezeCards')?changeShareVer():submitUnFreezeCards()"   
            :disabled="disabled"
            >提交</el-button
          >
 
        </div>
      </el-dialog>

    </div>

    <div v-else>
      <userItem
        @changUser="changUser"
        :isUser="isUser"
        :uitemInfo="uitemInfo"
        :fatherName="fatherName"
      ></userItem>
    </div> 

<!--  代理商绑定-->
    <el-dialog
      :close-on-click-modal="false"
      title="绑定用户"
      :visible.sync="addUserVisible"
      min-width="40%" 
      @close="closeDialog('addUser')"
    >
      <el-form label-min-width="180px" class="myForm" ref="addUserRef">
        <el-form-item label="绑定用户" class="select10 wid-9">
          
          <el-select
            size="small"
            v-model="userIDList"
            filterable
            multiple
            value-key="userId"
            placeholder="请输入用户名称"
            style="width: 100%"
          >
            <el-option
              v-for="item in userBindList"
              :key="item.userId"
              :label="`${item.userName}[${item.userId}]`"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog('addUser')">取消</el-button> 
        <el-button
          size="small"
          type="primary"
          :loading="loading"
          class="title"
          @click="verArry.includes('/api/admin/bindingAgent')?changeAdduserchVer():addUserSubmit()"
          >提交</el-button
        >
      </div>
    </el-dialog>

    <!-- 转出转入界面 -->
    <el-dialog
      :title="titleZhuan"
      :close-on-click-modal="false"
      :visible.sync="zhuanFormVisible"
      min-width="50%"
      @close="closeDialog('editForm')" 
      v-if="zhuanFormVisible"
    >
      <el-form :model="zhuanForm" :rules="rulesEdit" ref="editForm" label-min-width="140px">  
        <el-form-item label="中心钱包余额：">
          {{ zhuanForm.balance }}
        </el-form-item> 
        <el-form-item label="共享卡钱包余额：" >
          {{ zhuanForm.matrixBalance }}
        </el-form-item>
        
        <el-form-item label="转账金额" prop="transferAmount">
          <el-input
            size="small"
            v-model="zhuanForm.transferAmount"
            auto-complete="off"
            placeholder="请输入金额"
            :max="titleZhuan=='转出'? zhuanForm.matrixBalance:999999"
          ></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            size="small"
            v-model="zhuanForm.remark"
            auto-complete="off"
            placeholder="请输入备注"
          ></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button 
          @click="zhuanFormVisible=false"
        >
          取消
        </el-button>
        <el-button
        type="primary" 
          :disabled="disabled"
          @click="submitFormZhuan" 
        >
          确定
        </el-button>
      </div>
    </el-dialog>

    <!-- 转出转入 万里汇界面 -->
    <el-dialog
          :title="titleWlh"
          :close-on-click-modal="false"
          :visible.sync="wlhFormVisible"
          min-width="50%"
          @close="closeDialog('wlheditForm')" 
          v-if="wlhFormVisible"
        >
          <el-form :model="zwlhForm" :rules="wlhrulesEdit" ref="wlheditForm" label-min-width="140px">  
            <!-- <el-form-item label="中心钱包余额：">
              {{ zwlhForm.balance }}
            </el-form-item> 
            <el-form-item label="共享卡钱包余额：" >
              {{ zwlhForm.matrixBalance }}
            </el-form-item> -->

            <el-form-item label="万里汇钱包余额：" >
              {{ zwlhForm.budgetBalance }}
            </el-form-item>
            
            <el-form-item label="转账金额" prop="transferAmount">
              <el-input
                size="small"
                v-model="zwlhForm.transferAmount"
                auto-complete="off"
                placeholder="请输入金额"
                :max="titleZhuan=='转出'? zwlhForm.matrixBalance:999999"
              ></el-input>
            </el-form-item>
            <el-form-item label="备注">
              <el-input
                size="small"
                v-model="zwlhForm.remark"
                auto-complete="off"
                placeholder="请输入备注"
              ></el-input>
            </el-form-item>
          </el-form>

          <div slot="footer" class="dialog-footer">
            <el-button 
              @click="wlhFormVisible=false"
            >
              取消
            </el-button>
            <el-button
            type="primary" 
              :disabled="disabled"
              @click="submitFormWlh"  
            >
              确定
            </el-button>
          </div>
    </el-dialog>
 

    <codeChoose ref="codeRef" :fromType="verType" @setParam="getParam" @refresh="getdata(formInline)"></codeChoose>
    <ChangeDetails
      ref="changeDetails"
       :visble="changeDetailsVisible"
       v-if="changeDetailsVisible"
       :curItem="curItem"
       @close="changeDetailsVisible=false"
    ></ChangeDetails>
  </div>
</template>


<script>
import { mapState, mapGetters } from "vuex";
import codeChoose from '@/components/codeChoose.vue'
import ChangeDetails from "./ChangeDetails.vue";
import {
  setStoreS,
  getStoreS,
  removeStoreS,
  insertCharacter,
  spStr,
} from "../../utils/util";
import {
  baseURL,
  req,
  reqJson,
  encrypt,
  decrypt,
  reqtoken,
  service,
  format,
  getUrl,
} from "../../api/axiosFun";
import Pagination from "../../components/Pagination";
import userItem from "./userItem.vue";
export default {
  data() {
    return {
      changeDetailsVisible:false,
      isUser: true,
      loading: false,
      disabled: false,
      addFormVisible: false,
      resetFormVisible: false,
      shareFormVisible: false,
      cutFormVisible: false,
      addUserVisible:false,
      zhuanFormVisible:false,
      cardVisible:false,
      zhuanForm:{},
      titleZhuan:'转出', 
      titleWlh:'转出',
      wlhFormVisible:false,
      zwlhForm:{},
      wlhrulesEdit:{
         transferAmount:[
            { required: true, message: "请输入金额", trigger: "blur" },
          ], 
      },
      rulesfreezeBalance:{
         amount:[
            { required: true, message: "请输入金额", trigger: "blur" },
          ], 
      },
      
      b: format,
      fatherName: "会员管理",
      statusData: [
        { key: "未认证", value: 0 },
        // { key: "未认证", value: 1 },
        { key: "认证成功", value: 2 },
      ],
      statusJson: [
        { key: "未认证", value: 0 },
        { key: "未认证", value: 1 },
        { key: "认证成功", value: 2 },
      ],
      uitemInfo: "",
      addForm: {
        amount: "",
        remark: "",
        userId: "",
        rechargeAmount:''
      },
      cutForm: {
        amount: "",
        remark: "",
        userId: "",
        rechargeAmount:''
      },
      rulesReset: {
        password: [
          { required: true, message: "请输入新密码", trigger: "blur" },
        ],
        confirmPassword: [
          { required: true, message: "请再次确认密码", trigger: "blur" },
        ],
      },
      rulesEdit: {
        transferAmount: [
          { required: true, message: "充值金额", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.\d{1,2})?$/,
            message: "请输入正整数或者2位数小数",
            trigger: "blur",
          },
        ]
      }, 

      rulesShare: {
        shareCardCount: [
          {
            required: true,
            message: "请输入可开通共享卡数量",
            trigger: "blur",
          },
          {
            pattern: /^\d+$/,
            message: "请输入正确的数量",
            trigger: "blur",
          },
        ],
      },
      // rules表单验证
      rulesAdd: {
        amount: [
          { required: true, message: "到账金额", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.\d{1,2})?$/,
            message: "请输入正整数或者2位数小数",
            trigger: "blur",
          }, 
        ],
        rechargeAmount: [
          { required: true, message: "充值金额", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.\d{1,2})?$/,
            message: "请输入正整数或者2位数小数",
            trigger: "blur",
          }, 
        ], 

      },
      rulesCut: {
        amount: [
          { required: true, message: "请输入扣款金额", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.\d{1,2})?$/,
            message: "请输入正整数或者2位数小数",
            trigger: "blur",
          },
        ],
        remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
      },
      resetForm: {
        id: "",
        password: "",
        confirmPassword: "",
      },
      shareForm: {
        id: "",
        shareCardCount: "",
      },
      formInline: {
        pageNum: 1,
        pageSize: 10,
        authType: "",
        loginName: "",
        userId: "",
        compute:0
      },
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10,
      },
      hasPermission5:false,
      hasPermission6:false,
      hasPerDel:false,
      hostname:"https://dev.novalinkpay.com/", 
      // hostname: 'https://vip.novalinkpay.com/',
      verArry:[],
      verType:'',
      curItem:'',
      options:[],
      userIDList:[],
      userBindList:[],
      freezeBalanceVisible:false,
      freezeBalanceTitle:'',
      freezeBalanceForm:{
        amount:''
      }

    };
  },
  // 注册组件
  components: {
    Pagination,
    userItem,
    codeChoose,
    ChangeDetails
  },
  computed: {
    ...mapGetters(["getUser"]), 
  },
  watch: {
    getUser(newVal) {
      this.userInfo = JSON.parse(newVal);
      this.hasPermission5 = this.$hasPermission(this.userInfo,['common','user5','admin5','admin']) 
      this.hasPermission6 = this.$hasPermission(this.userInfo,['common','user6','admin6','admin']) 
      this.hasPerDel = this.$hasPermission(this.userInfo,['common','admin'])  
    },
  }, 

  created() {
    this.getdata(this.formInline);
    reqJson("get", "/api/photon/getUserInfo", {})
    .then((res) => { 
      if (res.code == 0) { 
        this.$store.commit("user", JSON.stringify(res.data));
        this.userInfo = res.data;
        if(this.userInfo&&this.userInfo.verifyApi){
          this.verArry =  this.userInfo.verifyApi.split(',');
        }  
      } else {
        this.$message({
          type: "info",
          message: res.msg,
        });
      }
    })
    .catch((err) => {}); 
    if(this.$store.state.user){
      this.userInfo = JSON.parse(this.$store.state.user);
      this.hasPermission5 = this.$hasPermission(this.userInfo,['common','user5','admin5','admin']) 
      this.hasPermission6 = this.$hasPermission(this.userInfo,['common','user6','admin6','admin']) 
      this.hasPerDel = this.$hasPermission(this.userInfo,['common','admin'])  
    }   
    this.getUserList(); 
  },
  methods: { 
    submitFormWlh(){ 
      let apiUrl  = '/api/admin/transferInBudget'
      if(this.titleWlh=="转出"){
          apiUrl = '/api/admin/transferOutBudget' 
      }else{

      }  
      let params = { 
        transferAmount:this.zwlhForm.transferAmount,
        userId:this.zwlhForm.userId, 
        remark:this.zwlhForm.remark,
      };
    
      let  url = getUrl(params);  
      reqJson('post',apiUrl  + url, { 
      },{
        headers:{
          ...this.headers
        }
      }) 
      .then((res) => {
        this.disabled = false;
        if (res.code == 0) {
          this.$message.success("操作成功");
          this.getdata(this.formInline); 
          this.closeDialog('editForm');
        } else {
          this.$message({
            type: "info",
            message: spStr(res.msg, "PhotonPay", ""),
          });
        }
      })
      .catch((err) => {
        this.$message.error(spStr(err, "PhotonPay", ""));
      });
    },
    changeBudgetAccount(row,state){
      this.titleWlh = state==2?'转入':'转出';
      this.zwlhForm = {
        ...this.zwlhForm,
        ...row,
      }; 
      this.wlhFormVisible = true;
    },
    openBudgetAccount(row){
      this.$alert('确定开通万里汇共享卡吗？', '提示', {
          confirmButtonText: '确定',
          callback: action => { 
            service
            .post("/api/admin/openBudgetAccount/"+row.userId, {})
            .then((res) => { 
              this.$message.success(spStr(res.msg, "PhotonPay", ""));
            })
            .catch((err) => {
              this.$message.error(spStr(err, "PhotonPay", ""));
            }); 
          }
        });
    },
    
    showBalance(item) {
      this.curItem = item
      this.changeDetailsVisible = true
    },


    hasPermissionMethod(data) {
      // 调用全局公共方法
      if(this.$store.state.user){
        this.userInfo = JSON.parse(this.$store.state.user);
        return this.$hasPermission(this.userInfo,data) 
      }
      
    },

    getUserList() {
      service
        .get("/api/admin/getNoRateConfigUsers", {})
        .then((res) => {
          this.loading = false; 
          this.options = res; 
        })
        .catch((err) => {
          this.$message.error(spStr(err, "PhotonPay", ""));
        });
    },

    getdata(parameter) {
      let url = getUrl(parameter);
      service
        .get("/api/admin/getUserList" + url, {})
        .then((res) => {
          this.loading = false;
          if (res.code == 0) {
            this.listData = res.rows;
            this.pageparm.currentPage = this.formInline.pageNum;
            this.pageparm.pageSize = this.formInline.pageSize;
            this.pageparm.total = res.total;
          } else {
            this.$message({
              type: "info",
              message: res.msg,
            });
          }
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error(spStr(err, "PhotonPay", ""));
        });
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.pageNum = parm.currentPage;
      this.formInline.pageSize = parm.pageSize;
      this.getdata(this.formInline);
    },
    // 搜索事件
    search() {
      this.getdata(this.formInline);
    },
    changUser(k, row) {
      this.isUser = k;
      this.uitemInfo = row;
      if (k) {
        this.getdata(this.formInline);
      }
    },
    handleShare(index, row) {
      this.shareFormVisible = true;
      this.shareForm.id = row.userId;
      this.curItem = row
    },
    handleEdit(index, row) {
      this.addForm.userId = row.userId;
      this.addFormVisible = true;
    },
    handleCut(index, row) {
      this.cutForm.userId = row.userId;
      this.cutFormVisible = true;
      this.uitemInfo = row;
    },
    handleReset(index, row) {
      this.resetFormVisible = true;
      this.resetForm.id = row.userId;
    },
    handleUser(index, row) {
      this.curItem = row
      let title = "停用后该用户将无法使用,请问您确定要停用吗？",
        msg = "已取消停用",
        status = 1;
      if (row.status == 1) {
        title = "启用后该用户将正常使用,请问您确定要启用吗？";
        msg = "已取消启用";
        status = 0;
      }
      let that = this
      this.$confirm(title, "信息", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
           
          if(that.verArry.includes('/api/admin/enableAccount')&&status == 0){
            that.verType = 'enableAccount' 
            that.$refs.codeRef.openDialog(); 
          }else if(that.verArry.includes('/api/admin/disableAccount')&&status == 1){
            that.verType = 'disableAccount' 
            that.$refs.codeRef.openDialog(); 
          }else{
            that.getAccount(status)
          } 
          // 账号停用 /api/admin/disableAccount
          // 账号启用 /api/admin/enableAccount  
          
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: msg,
          });
        });
    },
    getAccount(status){ 
      let obj = { status: status };
        let url = status==0?'/api/admin/enableAccount':'/api/admin/disableAccount'; 
          reqJson('post',url+"/" + this.curItem.userId, obj,{
            headers:{
              ...this.headers
            }
          })   
          .then((res) => {
            if (res.code == 0) {
              this.getdata(this.formInline);
            } else {
              this.$message.error(res.msg);
              return;
            }
          })
          .catch((err) => {
            this.disabled = false;
            this.$message.error(spStr(err, "PhotonPay", ""));
          });
    }, 

    delUser(index, row) {
      this.curItem = row;
      let that = this
      this.$confirm("删除后该用户将无法使用,请问您确定要删除吗？", "信息", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // let obj = { status: status };
          if(that.verArry.includes('/api/admin/deleteUserInfo')){
            that.verType = 'deleteUserInfo' 
            that.$refs.codeRef.openDialog(); 
          }else{
            that.sureDel()
          }
          
          
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: msg,
          });
        });
    },
    dongUser(index,row,type){ //冻结金额 freeze unfreeze
        this.freezeBalanceVisible = true
        this.curItem = row;
        this.freezeBalanceTitle =type=='freeze'? '解冻' : '冻结'
    },
    submitUnFreezeCards(){
      let url = getUrl({ 
        userId:this.curItem.userId,
        type:this.freezeBalanceTitle=='解冻'? 'unfreeze' : 'freeze',
        amount:this.freezeBalanceForm.amount,
        remark:this.freezeBalanceForm.remark,

      });
      reqJson('post',"/api/admin/freezeBalance"+url,{}).then(res=>{
        if(res && res.code==0){
          this.closeDialog('freezeBalance'); 
          //信息提示
          this.$message.success(res.msg)
        }else{ 
          this.$message.error(res.msg)
        }
      })
    },
    sureDel(){
      reqJson('post',"/api/admin/deleteUserInfo/" + this.curItem.userId,{ 
        },{
          headers:{
            ...this.headers
          }
       })   
      // service
      // .post("/api/admin/deleteUserInfo/" + this.curItem.userId)
      .then((res) => {
        if (res.code == 0) {
          this.getdata(this.formInline);
        } else {
          this.$message.error(res.msg);
          return;
        }
      })
      .catch((err) => {
        this.disabled = false;
        this.$message.error(spStr(err, "PhotonPay", ""));
      });
    },

    RechargeVer(){
      this.$refs.addForm.validate((valid) => {
        if (!valid) return;
        this.verType = 'recharge' 
        this.$refs.codeRef.openDialog();   
        return 
      });
    },
    submitFormAdd() {
      this.$refs.addForm.validate((valid) => {
        if (!valid) return;
        let url = getUrl(this.addForm);
        // this.disabled = true;
        // service.post("/api/admin/supporterRecharge" + url)

        reqJson('post',"/api/admin/supporterRecharge" + url,{ 
        },{
          headers:{
            ...this.headers
          }
        })   
        .then((res) => {
          if (res.code == 0) {
            this.disabled = false;
            this.closeDialog("addForm");
            this.getdata(this.formInline);
          } else if (res.code == 500) {
            this.$message.error(spStr(res.msg, "PhotonPay", ""));
            return;
          }
        });
      });
    },
    FormCutVer(){
      this.$refs.cutForm.validate((valid) => {
        if (!valid) return;
        this.verType = 'formCut' 
        this.$refs.codeRef.openDialog();   
        return 
      });
    },
    submitFormCut() {
      this.$refs.cutForm.validate((valid) => {
        if (!valid) return;
        let url = getUrl(this.cutForm);
        this.disabled = true;
        // service
        //   .post("/api/admin/supporterWithhold" + url)

          reqJson('post',"/api/admin/supporterWithhold" + url,{ 
        },{
          headers:{
            ...this.headers
          }
        })   
          .then((res) => {
            this.disabled = false;
            if (res.code == 0) {
              this.closeDialog("cutForm");
              this.getdata(this.formInline);
            } else {
              this.$message.error(spStr(res.msg, "PhotonPay", ""));
              return;
            }
          })
          .catch((err) => {
            this.disabled = false;
            this.$message.error(spStr(err, "PhotonPay", ""));
          });
      });
    }, 
    
    submitFormReset() {
      this.$refs.resetForm.validate((valid) => {
        if (!valid) return; 
         
        if (this.resetForm.password === this.resetForm.confirmPassword) {
          this.verType = 'setPwd'; 
           this.$refs.codeRef.openDialog();   
        } else {
          this.$message.error("两次密码不一致，请重新输入！");
        }
      });
    },

    setPwd() {
          let obj = { password: encrypt(this.resetForm.password) };
          reqJson('post',"/api/admin/resetPassword/"+this.resetForm.id,{
            ...obj
          },{
          headers:{
            ...this.headers
          }
        })  
     
        .then((res) => {
          if (res.code == 0) {
            this.disabled = false;
            this.$message.success('修改成功');
            this.closeDialog("resetForm");
            
          } else {
            this.$message.error(res.msg);
            return;
          }
        })
        .catch((err) => {
          this.disabled = false;
          this.$message.error(err);
        });
    },
    changeShareVer(){ // 
      this.$refs.shareForm.validate((valid) => {
        if (!valid) return;
        this.verType = 'changeShare' 
        this.$refs.codeRef.openDialog();   
        return 
      })
    
    },
    submitFormShare() {
      this.$refs.shareForm.validate((valid) => {
        if (!valid) return;
        let obj = { shareCardCount: this.shareForm.shareCardCount };  
        reqJson('post',"/api/admin/setShareCardNum/" + this.shareForm.id+'?shareCardCount='+this.shareForm.shareCardCount,{},{
          headers:{
            ...this.headers
          }
        })   
        .then((res) => {
            if (res.code == 0) {
              this.disabled = false;
              this.getdata(this.formInline);
              this.closeDialog("shareForm");
            } else {
              this.$message.error(res.msg);
              return;
            }
          })
          .catch((err) => {
            this.disabled = false;
            this.$message.error(err);
          });
      });
    },
    agantNumber(row){
      this.addUserVisible = true;
      this.curItem = row
      reqJson('get',"/api/admin/getBindingAgent/" + row.userId,{ 
        },{
        headers:{
          ...this.headers
        }
      })  
      .then((res) => {
        if (res.code == 0) { 
          this.userIDList =res.data.bindingIds.map(item=>item.userId);
          this.userBindList = [...res.data.bindingIds,...res.data.unBindingIds]; 
          // this.getdata(this.formInline);
        } else {
          this.$message.error(res.msg);
          return;
        }
      })
      .catch((err) => {
        // this.disabled = false;
        this.$message.error(err);
      }); 


    },
    changeAdduserchVer(){
      if(this.userIDList&&this.userIDList.length>0){
        this.verType = 'addUserVer' 
        this.$refs.codeRef.openDialog();   
      }else{
        this.$message.error('请选择绑定的用户');
      }
      
    },
    addUserSubmit(val){
      // /htp/api/admin/getBindingAgent/{userId} /htp/api/admin/bindingAgent/{userId}
      reqJson('post',"/api/admin/bindingAgent/" + this.curItem.userId,{ 
        ids:this.userIDList
        },{
        headers:{
          ...this.headers
        }
      })  
      .then((res) => {
        if (res.code == 0) { 
          this.getdata(this.formInline);
          this.closeDialog('addUser')
        } else {
          this.$message.error(res.msg);
          return;
        }
      })
      .catch((err) => {
        // this.disabled = false;
        this.$message.error(err);
      }); 
    },
    // 关闭编辑、增加弹出框
    closeDialog(name) {
      if (name == "resetForm") {
        this.resetFormVisible = false;
        this.$refs.resetForm.resetFields();
      } else if (name == "cutForm") {
        this.cutFormVisible = false;
        this.$refs.cutForm.resetFields();
      } else if (name == "shareForm") {
        this.shareFormVisible = false;
        this.$refs.shareForm.resetFields();
      } else if (name == "addUser") {
        this.addUserVisible = false;
        this.userIDList = []
        this.$refs.addUserRef.resetFields();
      } else if (name == "editForm") {
        this.zhuanFormVisible = false; 
        this.$refs.editForm.resetFields();
      } else if (name == "freezeBalance") {
        this.freezeBalanceVisible = false; 
        this.$refs.freezeBalanceForm.resetFields();
      } 
      
  

      else {
        this.addFormVisible = false;
        this.$refs.addForm.resetFields();
      }
    },
    getParam(val,type){ 
      this.headers = val
      if(type=="changeAgent"){
        this.changeSwitch(!this.curItem.agent,this.curItem); 
      }else if(type=="changeShare"){  
        this.submitFormShare(); 
      }else if(type=="addUserVer"){ 
        this.addUserSubmit(); 
      }else if(type=="recharge"){ 
        this.submitFormAdd(); 
      }else if(type=="formCut"){ 
        this.submitFormCut(); 
      }else if(type=="deleteUserInfo"){ 
        this.sureDel(); 
      } 
      else if(type=="enableAccount"){ 
        this.getAccount(0)
      }else if(type=="disableAccount"){ 
        this.getAccount(1);
      }else if(type=="setPwd"){
        this.setPwd();
      }else if(type=="zhuanChu"||type=="zhuanRu"){
        this.editZhuan()  
      }else if(type=="openMatrixAccount"){  
        this.changeGongSwitchEdit(); 
      }
    }, 
   
    changeSwitchVer(val){
      this.verType = 'changeAgent'
      this.curItem = val
      this.$refs.codeRef.openDialog();   
      return 
    },
    changeSwitch(e,val){ 
      // 设置代理商 /api/admin/setAgent
      //    取消代理商 /api/admin/cancelAgent
      let obj = { agent: e==true?1:0 };
      let url = e==true?'/api/admin/setAgent':'/api/admin/cancelAgent';
      reqJson('post',url +"/" + val.userId,{ 
        },{
        headers:{
          ...this.headers
        }
      })  
      .then((res) => {
        if (res.code == 0) { 
          this.getdata(this.formInline);
          // this.closeDialog("shareForm");
        } else {
          this.$message.error(res.msg);
          return;
        }
      })
      .catch((err) => {
        // this.disabled = false;
        this.$message.error(err);
      }); 

    },
    editZhuan(){
      let apiUrl  = '/api/admin/transferOutMatrix'
      if(this.titleZhuan=="转入"){
          apiUrl = '/api/admin/transferInMatrix' 
      }else{

      }  
      let  url = getUrl(this.zhuanForm);  
      reqJson('post',apiUrl  + url, {
        // ...this.editForm
      },{
        headers:{
          ...this.headers
        }
      }) 
      .then((res) => {
        this.disabled = false;
        if (res.code == 0) {
          this.$message.success("操作成功");
          this.getdata(this.formInline); 
          this.closeDialog('editForm');
        } else {
          this.$message({
            type: "info",
            message: spStr(res.msg, "PhotonPay", ""),
          });
        }
      })
      .catch((err) => {
        this.$message.error(spStr(err, "PhotonPay", ""));
      });
         
       
    },
    submitFormZhuan(){ 
      this.$refs.editForm.validate((valid) => {
        if (!valid) return; 
        this.verType = this.titleZhuan=="转入"?'zhuanChu':"zhuanRu"   
        if(this.titleZhuan=="转入"){ 
          if(this.verArry.includes('/api/admin/transferInMatrix')){ 
            this.zhuanFormVisible = false;
            this.$refs.codeRef.openDialog(); 
          }else{
            this.editZhuan()
          }
        }else{
          if(this.verArry.includes('/api/admin/transferOutMatrix')){ 
            this.zhuanFormVisible = false;
            this.$refs.codeRef.openDialog(); 
          }else{
            this.editZhuan()
          }
        }   
         
      });

    },
    changeGongZhuan(row,type){
      this.titleZhuan=type==1?'转出':'转入';
      this.zhuanFormVisible = true ;
      this.zhuanForm = {
        userId:row.userId,
        balance:row.balance,
        matrixBalance:row.matrixBalance,
      }; 
    },

    changeGongSwitchEdit(val){ 
       let url =  '/api/admin/openMatrixAccount';
        reqJson('post',url +"/" + this.curItem.userId,{ 
          },{
          headers:{
            ...this.headers
          }
        })  
        .then((res) => {
          if (res.code == 0) { 
            this.getdata(this.formInline); 
          } else {
            this.$message.error(res.msg);
            return;
          }
        })
        .catch((err) => { 
          this.$message.error(err);
        }); 
    },
    changeGongSwitch(val){ 
      this.curItem = val
      if(this.verArry.includes('/api/admin/openMatrixAccount')){ 
        this.verType = 'openMatrixAccount'
        this.$refs.codeRef.openDialog(); 
      }else{
        this.changeGongSwitchEdit(); 
      } 
     

    },

    
    exportEx() {
      let url = getUrl(this.formInline);
      service
        .post("api/admin/exportUserList" + url, {})
        .then((res) => {
          this.loading = false; 
          if (res.code == 0) {
            window.open(
              baseURL + "/common/download?fileName=" + res.msg,
              "_blank"
            );
          } else {
            this.$message({
              type: "info",
              message: spStr(res.msg, "PhotonPay", ""),
            });
          }
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error(spStr(err, "PhotonPay", ""));
        });
    },
 
  },


  directives: {
    // 注册一个复制指令
    copy: {
      bind(el, { value }) {
        el.handler = () => {
          if (!value) {
            console.error('需要复制的内容不能为空'); 
            return;
          }
          const input = document.createElement('input');
          input.value = value;
          document.body.appendChild(input);
          input.select();
          document.execCommand('copy');
          document.body.removeChild(input);
          alert('复制成功！') 
        }; 
        el.addEventListener('click', el.handler);
      },
      unbind(el) {
        el.removeEventListener('click', el.handler);
      },
    },
  },

};
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
</style>

 
 